<?php
/**
 * 描述：资讯-专题列表。
 * @final
 */
final class Exec_News_Topic_List extends Exec_News_Public
{
    public function Get()
    {
        parent::Get();

        #获取参数
        $type=Functions::UrlArgs('type');

        #定义标量
        $contentTitle=NULL;
        $params=array();

        #获取数据
        switch($type)
        {
            case 'class':                
                $classID=trim(Functions::UrlArgs('id'));
                if(!is_numeric($classID))
                {
                    echo $classID;
                    return;
                }
                $data=DB::GetData('select * from topic where ClassID='.$classID.' order by Datetime desc limit ?,20');
                $params['id']=$classID;
                $contentTitle=DAO_TopicClass::GetNameByID($classID);
            break;
            case 'ranking':                
                $contentTitle='专题排行';
				$data=DB::GetData('select * from topic order by VisitsCount desc limit ?,10');
            break;			
            default:
                $data=DB::GetData('select * from topic order by ID desc limit ?,20');
                $contentTitle='最新专题';
            break;
        }

        #配置参数
        $params['type']=$type;

		#处理数据
        foreach($data['Record'] as &$row)
        {            
            $row['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_TOPIC.'/'.$row['ThumbnailPath'];
        }		

        #渲染输出
        View::Assign('TopicList_Data',@$data['Record']);
        View::Assign('TopicList_PageMenu',PagerFactory::Create('Common')->Fetch($data,array
        (
            'URL'=>'/exec.php?action=news_topic_list',
            'Parameters'=>$params,
            'IsDetail'=>TRUE
        )));
        View::Assign('ContentTitle',$contentTitle);
        View::Display('news/topic/list.tpl');
    }
}
?>